﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Data.Linq;
using System.Collections;
using System.ComponentModel;

namespace ProSOLD
{
  /// <summary>
  /// Interaction logic for admin_hq.xaml
  /// </summary>
  public partial class admin_hq : Page
  {
   


    int xc = 1;

    public admin_hq()
    {
      InitializeComponent();

      lblCurrentValue.Content = xc;


    }

    #region DbTanımlama
    const string ConnState = @"Data Source=.\SQLEXPRESS; AttachDbFilename=""|DataDirectory|\Database1.mdf""; Integrated Security = True; User Instance = True";
    #endregion



    DataContext db = new DataContext(ConnState);

    public void veri()
    {

      label7.RenderTransform = new RotateTransform(90);



      Table<evBilgisi> tablom = db.GetTable<evBilgisi>();

       int sayici = (from c in tablom select c.id).Count();


       #region Değerler

       var baglandi = (from c in tablom where c.id == xc select c.ev_uydu);

      string adresdegiskeni = baglandi.First().ToString();

      Uri baglandimiz = new Uri(adresdegiskeni);

      webbrowse.Source = baglandimiz;

      var x = (from c in tablom where c.id == xc select c.ev_Sahibi).ToList();
      textBox1.Text = x.First().ToString();


      var no = (from c in tablom where c.id == xc select c.ev_telefonu).ToList();
      textBox2.Text = no.First().ToString();


      var bilgi = (from c in tablom where c.id == xc select c.ev_adresi).ToList();
      textBox3.Text = bilgi.First().ToString();

      var tip = (from c in tablom where c.id == xc select c.ev_bilgisi).ToList();
      textBox4.Text = tip.First().ToString();

      var yok = (from c in tablom where c.id == xc select c.ev_yorumlari).ToList();
      textBox5.Text = yok.First().ToString();
       #endregion


      listBox1.DataContext = x;


    }


    private void MenuItem_Click(object sender, RoutedEventArgs e)
    {
      ProSOLD.Splash sp = new Splash();

      sp.Show();


    }


    

    private void button2_Click(object sender, RoutedEventArgs e)
    {
      Admin_kira_ekle ekle = new Admin_kira_ekle();

      ekle.Show();


      MessageBox.Show(xc.ToString());
      veri();
      


    //  listView1.ItemsSource = (from c in tablom where c.id==1 select c.ev_adresi).ToList();

   



        /*
      var yok = from tablo in tablom select tablo;
      
      foreach (var zok in yok)
      {
        Console.WriteLine(zok.adi);


      }





   //   ICollectionView view = CollectionViewSource.GetDefaultView(yokx.adi);

      listBox1.DataContext = view;
        */


    }

    private void button3_Click(object sender, RoutedEventArgs e)
    {
      
      
      
      
      
      
      /*
      textBox1.Text = ""; textBox2.Text = ""; textBox3.Text = ""; textBox4.Text = "";
      textBox5.Text = "";

      Uri x = new Uri("http://www.google.com");
      webbrowse.Source = x;


      Table<evBilgisi> tablom = db.GetTable<evBilgisi>();

      int sayici = (from c in tablom select c.id).Count();
  

      try
      {


        xc += 1;
      }
      catch
      {
        MessageBox.Show("Bitti");
      }

      */
   //   var idSecelim = from idSecimi in tablom where idSecimi.id == 1 select idSecimi.id;

     

    }
    

    private void repeatAddValueButton_Click(object sender, RoutedEventArgs e)
    {

      DataContext dat = new DataContext(ConnState);

      Table<evBilgisi> evim = dat.GetTable<evBilgisi>();


      var selection = (from i in evim select i.id).Count();


      while (xc < selection)
      {
        lblCurrentValue.Content = xc;

        xc = xc + 1;

        selection -= 1;
        veri();
      }

    }

    private void repeatRemoveValueButton_Click(object sender, RoutedEventArgs e)
    {


      DataContext dat = new DataContext(ConnState);

      Table<evBilgisi> evim = dat.GetTable<evBilgisi>();


      if (xc == 0)
      {
        
       
      }
      else
      {
        veri();
        lblCurrentValue.Content = xc;
        xc--;
      }



        

    }

    private void button4_Click(object sender, RoutedEventArgs e)
    {

    }
  }
}
